<template>
  <div class="x-sort-item flex-c" @click="handleSort">
    <span>{{ label }}</span>
    <span class="x-sort-item-operation flex flex-col">
      <i class="el-icon-caret-top" :class="{'el-icon-caret-active': value === 1}"></i>
      <i class="el-icon-caret-bottom" :class="{'el-icon-caret-active': value === 0}"></i>
    </span>
  </div>
</template>

<script>
export default {
  name: 'SortItem',
  props: {
    value: {
      default: ''
    },
    label: {
      type: String,
      default: ''
    },
  },
  data() {
    return {
    };
  },
  methods: {
    handleSort () {
      if (this.value === '') {
        this.$emit('input', 1);
      } else if (this.value === 1) {
        this.$emit('input', 0);
      } else {
        this.$emit('input', '');
      }
      this.$emit('change');
    }
  },
  mounted() {
  }
};
</script>

<style lang="scss" scoped>
@import "@/css/variable.scss";
.x-sort-item {
  line-height: 1;
  color: $white5;
  cursor: pointer;
  padding: 22px 16px;
  .x-sort-item-operation {
    margin-left: 0.0933rem;
    color: $white4;
    i.el-icon-caret-active {
      color: $blue1;
    }
    i:nth-child(1) {
      transform: translateY(4px);
    }
    i:nth-child(2) {
      transform: translateY(-4px);
    }
  }
}
</style>
